<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" size="small" v-show="showSearch" label-width="68px">

      <el-form-item label="套餐名称" prop="comboName">
        <el-input
          v-model="queryParams.comboName"
          placeholder="请输入套餐名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="服务区域" prop="cityCode">
        <el-select v-model="queryParams.provinceCode" placeholder="请选择省" @change="initCity">
          <el-option
            v-for="item in provinceList"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
        <el-select v-model="queryParams.cityCode" @change="initArea" placeholder="请选择市" style="margin-left: 5px">
          <el-option
            v-for="item in cityList"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-radio-group v-model="queryParams.status" @change="handleQuery">
          <el-radio-button :label="undefined">全部</el-radio-button>
          <el-radio-button label="active">上架</el-radio-button>
          <el-radio-button label="inactive">下架</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['biz:combo:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['biz:combo:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-circle-check"
          size="mini"
          :disabled="multiple"
          @click="handleBatchChangeStatus('active')"
          v-hasPermi="['biz:combo:biz:combo:changeStatusBatch']"
        >批量上架
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-circle-close"
          size="mini"
          :disabled="multiple"
          @click="handleBatchChangeStatus('inactive')"
          v-hasPermi="['biz:combo:biz:combo:changeStatusBatch']"
        >批量下架
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="comboList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="套餐名称" align="center" prop="comboName">
        <template slot-scope="scope">
          <span style="cursor: pointer;color:#1c84c6;" @click="goDetail(scope.row)" v-hasPermi="['biz:combo:query']"
          >{{ scope.row.comboName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="包含服务" align="center" prop="serviceCount">
        <template slot-scope="scope">
          <el-tooltip :content="scope.row.serviceNames" placement="bottom" effect="light">
            <span style="cursor: pointer;color: #1c84c6;"
            >{{ scope.row.serviceCount }}【{{ scope.row.serviceNames }}】</span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="服务区域" align="center" prop="city">
        <template slot-scope="scope">
          <span>{{ scope.row.province }}{{ scope.row.city }}</span>
        </template>
      </el-table-column>
      <el-table-column label="服务医院" align="center" prop="hospitalCount">
        <template slot-scope="scope">
          <el-tooltip :content="scope.row.hospitalNames" placement="bottom" effect="light">
            <span style="cursor: pointer;color: #1c84c6;"
            >{{ scope.row.hospitalCount }}【{{ scope.row.hospitalNames }}】</span>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="套餐价格(陪护豆/个)" align="center" prop="price"/>
      <el-table-column label="服务人员" align="center" prop="nickNames"/>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <span v-if="scope.row.status === 'active'" style="color: green">上架</span>
          <span v-if="scope.row.status === 'inactive'" style="color: red">下架</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-show="scope.row.status==='inactive'"
            size="mini"
            type="text"
            icon="el-icon-check"
            style="color: #4AB7BD"
            @click="handleChangeStatus(scope.row)"
            v-hasPermi="['biz:combo:changeStatus']"
          >上架
          </el-button>
          <el-button
            v-show="scope.row.status==='active'"
            size="mini"
            type="text"
            icon="el-icon-close"
            style="color: #E65D6E"
            @click="handleChangeStatus(scope.row)"
            v-hasPermi="['biz:combo:changeStatus']"
          >下架
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['biz:combo:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-user"
            @click="handleRelationUser(scope.row)"
            v-hasPermi="['biz:combo:relationUser']"
          >关联人员
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改套餐对话框 -->
    <el-drawer
      :title="title"
      :visible.sync="open"
      size="40%"
      :show-close="true"
      :wrapperClosable="false"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="80px" style="margin-left: 20px">
        <el-form-item label="套餐图片" prop="comboImage">
          <el-upload
            class="avatar-uploader"
            accept="image/jpeg,image/png,image/jpg"
            :action="upload.url"
            name="multipartFile"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload"
          >
            <img v-if="form.comboImage" :src="form.comboImage" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            <div slot="tip" class="el-upload__tip" style="color: red">推荐上传jpg、png、jpeg文件，且不超过1MB</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="套餐名称" prop="comboName">
          <el-input v-model="form.comboName" maxlength="30" placeholder="请输入套餐名称" style="width: 70%"/>
        </el-form-item>
        <el-form-item label="包含服务" prop="serviceIds">
          <el-select v-model="form.serviceIds" placeholder="请选择服务" style="width: 70%" :reserve-keyword="true" filterable
                     multiple
          >
            <el-option
              v-for="item in serviceList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="套餐区域" prop="provinceCode">
          <el-select v-model="form.provinceCode" placeholder="请选择省" @change="initCity" style="width: 260px">
            <el-option
              v-for="item in provinceList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
          <el-select v-model="form.cityCode" @change="initArea" placeholder="请选择市"
                     style="margin-left: 27px;width: 260px"
          >
            <el-option
              v-for="item in cityList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="服务医院" prop="hospitalIds">
          <el-select v-model="form.hospitalIds" placeholder="请选择服务医院" style="width: 70%" filterable multiple>
            <el-option
              v-for="item in hospitalList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>

<!--        <el-form-item label="服务人员" prop="userId">-->
<!--          <el-select v-model="form.userId" placeholder="请选择服务人员" style="width: 70%" filterable>-->
<!--            <el-option-->
<!--              v-for="item in userList"-->
<!--              :key="item.userId"-->
<!--              :label="item.nickName"-->
<!--              :value="item.userId"-->
<!--            >-->
<!--            </el-option>-->
<!--          </el-select>-->
<!--        </el-form-item>-->

        <el-form-item label="套餐价格" prop="price">
          <el-input v-model="form.price" maxlength="10,2" placeholder="请输入服务价格"
                    oninput="value=value.replace(/[^0-9.]/g,'')" style="width: 70%"
          >
            <template slot="append">陪护豆</template>
          </el-input>
        </el-form-item>
        <el-form-item label="时长单位" prop="serviceTimeUnit">
          <el-radio-group v-model="form.serviceTimeUnit" @change="typeChange">
            <el-radio-button label="小时">小时</el-radio-button>
            <el-radio-button label="天">天</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="服务时长" prop="serviceTime">
          <el-input placeholder="请输入服务时长" onkeyup="value=value.replace(/[^\d]/g,'')" v-model="form.serviceTime"
                    style="width: 70%" maxlength="4"
          >
            <template slot="append" v-if="form.serviceTimeUnit == '小时'">小时</template>
            <template slot="append" v-else>天</template>
          </el-input>
        </el-form-item>
        <el-form-item label="状态" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio-button label="active">上架</el-radio-button>
            <el-radio-button label="inactive">下架</el-radio-button>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="套餐介绍" prop="introduction">
          <el-input v-model="form.introduction" type="textarea" placeholder="请输入服务介绍"
                    :autosize="{ minRows: 2, maxRows: 10}" maxlength="255" style="width: 70%"
          />
        </el-form-item>

      </el-form>
      <div style="text-align: center;margin-top: 70px">
        <el-button type="primary" :loading="submitLoading" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-drawer>
    <el-drawer
      title="套餐详情"
      :visible.sync="drawer"
      size="40%"
      :show-close="true"
      append-to-body
    >
      <el-form ref="form" :model="form" label-width="120px" size="mini">
        <el-row>
          <el-col :span="24">
            <el-form-item label="套餐图片：">
              <el-image :src="form.comboImage" style="width: 140px;height: 130px"
                        :preview-src-list="new Array(form.comboImage)"
              ></el-image>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="套餐名称：">{{ form.comboName }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="包含服务：">{{ form.serviceNames }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="套餐区域：">{{ form.province }}{{ form.city }}</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="服务医院：">{{ form.hospitalNames }}</el-form-item>
          </el-col>
<!--          <el-col :span="24">-->
<!--            <el-form-item label="服务人员：">{{ form.nickName }}</el-form-item>-->
<!--          </el-col>-->
          <el-col :span="24">
            <el-form-item label="套餐价格：">{{ form.price }}陪护豆</el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="套餐介绍：">{{ form.introduction }}</el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-drawer>

    <el-dialog title="关联人员" :visible.sync="userOpen" width="650px" append-to-body>
      <el-form ref="serviceUserForm" :model="serviceUserForm" :rules="rules" label-width="80px">
        <el-form-item label="服务人员" prop="userIds">
          <el-select v-model="serviceUserForm.userIds" placeholder="请选择服务人员" style="width: 70%" filterable multiple>
            <el-option
              v-for="item in userList"
              :key="item.userId"
              :label="item.nickName"
              :value="item.userId"
            >
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :loading="relationSubmitLoading" @click="relationSubmitForm">确 定</el-button>
        <el-button @click="relationCancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listCombo, getCombo, delCombo, addCombo, updateCombo, changeStatus,relationUser } from '@/api/biz/combo'
import { getToken } from '@/utils/auth'
import { getCityList } from '@/api/biz/city'
import { getHospitalList } from '@/api/biz/hospital'
import { getUserListByType } from '@/api/biz/escort'
import { getServiceList,listRelationUser } from '@/api/biz/service'

export default {
  name: 'Combo',
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 套餐表格数据
      comboList: [],
      hospitalList: [],
      userList: [],
      serviceList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      userOpen:false,
      drawer: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: undefined,
        comboName: undefined,
        comboImage: undefined,
        introduction: undefined,
        price: undefined,
        province: undefined,
        provinceCode: undefined,
        city: undefined,
        cityCode: undefined,
        hospitalIds: undefined,
        serviceIds: undefined,
        status: undefined
      },
      hospitalQueryParams: {
        cityCode: undefined,
        status: 'active'
      },
      serviceQueryParams: {
        status: 'active'
      },
      userQueryParams: {
        hospitalIds: [],
        userType: undefined
      },
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: '',
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: 'Bearer ' + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + '/common/uploadObs'
      },
      // 表单参数
      form: {},
      serviceUserForm: {},
      submitLoading: false,
      relationSubmitLoading: false,
      // 表单校验
      rules: {
        userId: [
          { required: true, message: '用户id不能为空', trigger: 'blur' }
        ],
        comboName: [
          { required: true, message: '套餐名称不能为空', trigger: 'blur' }
        ],
        comboImage: [
          { required: true, message: '套餐图片不能为空', trigger: 'blur' }
        ],
        serviceIds: [
          { required: true, message: '请选择包含服务', trigger: 'blur' }
        ],
        provinceCode: [
          { required: true, message: '请选择套餐区域', trigger: 'blur' }
        ],
        hospitalIds: [
          { required: true, message: '请选择服务医院', trigger: 'blur' }
        ],
        price: [
          { required: true, message: '套餐价格不能为空', trigger: 'blur' }
        ],
        userIds: [
          { required: true, message: '请选择服务人员', trigger: 'blur' }
        ],
        serviceTimeUnit: [
          { required: true, message: '请选择时长单位', trigger: 'blur' }
        ],
        serviceTime: [
          { required: true, message: '请选择服务时长', trigger: 'blur' }
        ],

      },
      provinceList: [],
      province: '',
      cityList: [],
      city: [],
    }
  },
  created() {
    this.getList()
    this.getCityList()
    this.getServiceList()
    this.getUserListByType()
  },
  methods: {
    typeChange(val) {
      this.form.serviceTimeUnit = val
    },
    /** 查询套餐列表 */
    getList() {
      this.loading = true
      listCombo(this.queryParams).then(response => {
        this.comboList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    getHospitalList() {
      getHospitalList(this.hospitalQueryParams).then(res => {
        this.hospitalList = res.data
      })
    },
    getUserListByType() {
      getUserListByType(this.userQueryParams).then(res => {
        this.userList = res.data
      })
    },
    getServiceList() {
      getServiceList(this.serviceQueryParams).then(res => {
        this.serviceList = res.data
      })
    },
    // 取消按钮
    cancel() {
      this.open = false
      this.reset()
    },
    relationCancel() {
      this.userOpen = false
      this.relationReset()
    },
    getIndex($index) {
      //表格序号
      return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userId: null,
        comboName: null,
        comboImage: null,
        introduction: null,
        price: null,
        province: null,
        provinceCode: null,
        city: null,
        cityCode: null,
        hospitalIds: null,
        serviceIds: null,
        status: 'active',
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
        remark: null,
        serviceTime: null,
        serviceTimeUnit: '小时',
      }
      this.resetForm('form')
    },
    relationReset() {
      this.serviceUserForm = {
        id: null,
        type:null,
        productId:null,
        userId:null,
        userIds:[],
      }
      this.resetForm('serviceUserForm')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.provinceCode = undefined
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.open = true
      this.title = '添加套餐'
    },
    handleChangeStatus(row) {
      let statusText = row.status === 'active' ? '下架' : '上架'
      let status = row.status === 'active' ? 'inactive' : 'active'
      const ids = [row.id] || this.ids
      this.$confirm('是否确认' + statusText + '该项数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return changeStatus({ ids: ids, status: status })
      }).then(() => {
        this.getList()
        this.msgSuccess('操作成功')
      }).catch(function() {
      })
    },
    handleBatchChangeStatus(status) {
      let statusText = status === 'active' ? '上架' : '下架'
      const ids = this.ids
      this.$confirm('是否确认' + statusText + '选中的数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return changeStatus({ ids: ids, status: status })
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('操作成功')
      }).catch(function() {
      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id || this.ids
      getCombo(id).then(response => {
        this.form = response.data
        let ids = this.form.hospitalIds.split(',')
        this.form.hospitalIds = []
        for (let i = 0; i < ids.length; i++) {
          this.form.hospitalIds.push(parseInt(ids[i]))
        }
        let serviceIds = this.form.serviceIds.split(',')
        this.form.serviceIds = []
        for (let i = 0; i < serviceIds.length; i++) {
          this.form.serviceIds.push(parseInt(serviceIds[i]))
        }
        this.form.provinceCode = parseInt(this.form.provinceCode)
        this.form.cityCode = parseInt(this.form.cityCode)
        if (response.data.provinceCode && response.data.cityCode) {
          this.showAddress(response.data.provinceCode, response.data.cityCode)
        }
        this.hospitalQueryParams.cityCode = this.form.cityCode
        this.getHospitalList()
        this.getServiceList()
        this.open = true
        this.title = '修改套餐'
      })
    },
    handleRelationUser(row){
      this.relationReset();
      this.serviceUserForm.type = "2";
      this.serviceUserForm.productId = row.id;
      //查询选中的userIds
      let query = {
        type:"2",
        productId:row.id
      }
      // if (row.type === '1') {
      //   this.userQueryParams.userType = '20'
      //   this.userQueryParams.hospitalIds = []
      // } else if (row.type === '2') {
      //   this.userQueryParams.userType = '30'
      //   this.userQueryParams.hospitalIds = []
      // } else if (row.type === '3') {
      //   if (row.hospitalIds) {
      //     let idsArr = row.hospitalIds.split(",")
      //     this.userQueryParams.userType = '40'
      //     this.userQueryParams.hospitalIds = idsArr;
      //   }
      // }
      // getUserListByType(this.userQueryParams).then(res => {
      //   this.userList = res.data;

      // })
      listRelationUser(query).then(res =>{
        this.serviceUserForm.userIds = [];
        this.serviceUserForm.userIds = res.data;
        this.userOpen = true;
      })
    },
    /** 提交按钮 */
    submitForm() {
      console.log('this.form', this.form)
      this.$refs['form'].validate(valid => {
        if (valid) {
          this.submitLoading = true
          if (this.form.id != null) {
            updateCombo(this.form).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.open = false
              this.submitLoading = false
              this.getList()
            }).catch(() => {
              this.submitLoading = false
            })
          } else {
            addCombo(this.form).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.open = false
              this.submitLoading = false
              this.getList()
            }).catch(() => {
              this.submitLoading = false
            })
          }
        }
      })
    },
    relationSubmitForm() {
      this.$refs['serviceUserForm'].validate(valid => {
        if (valid) {
          console.log('serviceUserForm', this.serviceUserForm)
          this.relationSubmitLoading = true
          relationUser(this.serviceUserForm).then(response => {
            this.$modal.msgSuccess('关联成功')
            this.userOpen = false
            this.relationSubmitLoading = false
            this.getList()
          }).catch(() => {
            this.relationSubmitLoading = false
          })
        }
      })
    },
    goDetail(row) {
      getCombo(row.id).then(response => {
        this.form = response.data
        this.drawer = true
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids
      this.$modal.confirm('是否确认删除套餐编号为"' + ids + '"的数据项？').then(function() {
        return delCombo(ids)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('biz/combo/export', {
        ...this.queryParams
      }, `combo_${new Date().getTime()}.xlsx`)
    },
    handleAvatarSuccess(res, file) {
      this.form.comboImage = res.data.url
    },
    beforeAvatarUpload(file) {
      const isLt2M = file.size / 1024 / 1024 < 1
      if (!isLt2M) {
        this.$message.error('上传图片大小不能超过 1MB!')
      }
      return isLt2M
    },
    //获取省市区列表
    getCityList() {
      getCityList({ code: '' }).then(response => {
        this.provinceList = response.data
      })
    },
    initCity(code) {
      this.cityList = []
      this.form.cityCode = undefined
      this.queryParams.cityCode = undefined
      this.form.hospitalIds = undefined
      getCityList({ code: code }).then(response => {
        this.cityList = response.data
      })
      let o = this.provinceList.find((item) => {
        return item.id == code//比如：选项2
      })
      this.province = o.name
      this.form.province = this.province
    },
    initArea(code) {
      this.form.hospitalIds = undefined
      let o = this.cityList.find((item) => {
        return item.id == code//比如：选项2
      })
      this.form.cityCode = code
      this.city = o.name
      this.form.city = o.name
      this.hospitalQueryParams.cityCode = code
      this.getHospitalList()
    },
    showAddress(provinceCode, cityCode) {
      var o = this.provinceList.find((item) => {
        return item.id == provinceCode//比如：选项2
      })
      this.province = o.name
      getCityList({ code: provinceCode }).then(response => {
        this.cityList = response.data
        var o = this.cityList.find((item) => {
          return item.id == cityCode//比如：选项2
        })
        this.city = o.name
      })
      // getCityList({code: cityCode}).then(response => {
      //   this.districtList = response.data;
      //   var o = this.districtList.find((item)=>{
      //     return item.id == areaCode;//比如：选项2
      //   });
      //   //this.district = o.name;
      // });
      setTimeout(() => {
        // this.valueChange();
      }, 600)
    }
  }
}
</script>
<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>

